<?php

session_start();


require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/auth.inc.php";

Class TalkForm extends Form {
	
	function TalkForm($database, $resource, $method = "GET") {
		$this->FORM($database,$resource,$method);
	}
	
	function editItem_postDeletion() {
		
	}
	
	function addItem_preInsertion() {
		
	}
	
	function addItem_postInsertion() {
		
		$users = aux::getResult("SELECT email FROM {$GLOBALS['usersEntity']->name} WHERE active_newsletter ='*'");
		
		$emails = "";
		foreach($users as $v) {
			$emails .= aux::first_comma("email". ", ").$v['email'];
		}
		
		$mail = new Template("skins/dipartimento/dtml/talk.mail");
		
		$mail->setContent("title", $_REQUEST['title']);
		$mail->setContent("author", $_REQUEST['author']);
		$mail->setContent("affiliation", $_REQUEST['affiliation']);
		$mail->setContent("abstract", $_REQUEST['abstract']);
		$mail->setContent("venue", $_REQUEST['venue']);
		$mail->setContent("date", $_REQUEST['date']);
		$mail->setContent("time", $_REQUEST['date_time']);
		
		$mail->setContent("id", $_REQUEST['insertid']);
		
		#aux::mail($_REQUEST['email'],"Seminario {$_REQUEST['author']}", $mail->get(), $_SESSION['user']['email']);
		aux::mail($emails,"Seminario {$_REQUEST['author']}", $mail->get(), $_SESSION['user']['email']);

		
	}	
}


$main = new Skin(); 

$form = new TalkForm("dataEntry",$talkEntity);

$form->addSection("Talk Management");

$form->addText("title", "Title", 70, MANDATORY);
$form->addText("author", "Author", 50, MANDATORY);
$form->addText("affiliation", "Affiliation", 70, MANDATORY);
$form->addText("website", "Home Page", 70);
$form->addTextarea("abstract", "Abstract", 6, 70);
$form->addLongDate("date", "Date", MANDATORY);
$form->addText("venue", "Where", 40);

switch($_REQUEST['action']) {
	case "add":
	$main->setContent("body",$form->addItem());
	break;
	case "edit":
	$main->setContent("body",$form->editItem());
	break;
}

$main->close();

?> 